Page({
  data: {
    name: '',
    gender: 1,
    mobile: '',
    currentDate: Date.now(),
    dateLayerVisible: false,
    houseLayerVisible: false,
    houseList: [],
  },
  
  openHouseLayer() {
    this.setData({ houseLayerVisible: true })
  },
  closeHouseLayer() {
    this.setData({ houseLayerVisible: false })
  },
  openDateLayer() {
    this.setData({ dateLayerVisible: true })
  },
  closeDateLayer() {
    this.setData({ dateLayerVisible: false })
  },
  onLoad() {
    this.getHouseList()
  },

  // 选择房屋
  selectHouse(ev) {
    console.log(ev.detail);
    this.setData({
      houseId: ev.detail.id,
      houseName: ev.detail.name
    })
  },
    // 获取房屋列表
    async getHouseList() {
      // 请求数据接口
      const { code, data } = await wx.http.get('/house')
      // 检测接口返回的结果
      if (code !== 10000) return wx.utils.toast()
      // 请求成功
      this.setData({ 
        houseList: data
       })
    },
  submitForm() {
    // 跳转到访客列表页
    wx.navigateTo({
      url: '/visitor_pkg/pages/list/index'
    })
  },
})
